package com.lill.system.api;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lill.common.component.util.OrderNumberUtil;
import com.lill.common.component.util.R;

@RestController
@RequestMapping("api/sysOrderNumber")
public class SysOrderNumberApi {



    /**
     * 前台添加手机号在单号的后面  时间只到时
     * @param paranMap
     * @param user
     * @return
     */
    @RequestMapping("getOrderNum")
    public R getOrderNumber(@RequestBody Map<String,Object> paranMap){
        Object type = paranMap.get("type");
        Object companyCode = paranMap.get("companyCode");
        Object branchCode = paranMap.get("branchCode");
//        Map<String,Object>map = new HashMap<>();
        String prefix = companyCode+"-"+branchCode+"-A";
        if (type != null) {
            prefix += type;
        }
        String orderNumber = prefix+OrderNumberUtil.getOrderNumberYYYYMMDDHH();
        R data = R.ok().put("data", orderNumber);
        return data;
    }

    /**
     * 前台没有手机号   时间到时分秒
     * @param paranMap
     * @param user
     * @return
     */
    @RequestMapping("getOrderNumMMSS")
    public R getOrderNumMMSS(@RequestBody Map<String,Object> paranMap){
        Object type = paranMap.get("type");
        Object companyCode = paranMap.get("companyCode");
        Object branchCode = paranMap.get("branchCode");
        String prefix = companyCode+"-"+branchCode+"-A";
        if (type != null) {
            prefix += type;
        }
        String orderNumber = prefix+OrderNumberUtil.getOrderNumberYYYYMMDDHHMMSS();
        R data = R.ok().put("data", orderNumber);
        return data;
    }
    @RequestMapping("getAppletsOrderNumMMSS")
    public R getAppletsOrderNumMMSS(@RequestBody Map<String,Object> paranMap){
        Object type = paranMap.get("type");
        String prefix = "";
        if (type != null) {
            prefix += type;
        }
        String orderNumber = prefix+OrderNumberUtil.getOrderNumberYYYYMMDDHHMMSS();
        R data = R.ok().put("data", orderNumber);
        return data;
    }


    /**
     * true ： 显示
     * false ：隐藏
     * @return
     */
    @RequestMapping("/isRegister")
    public R isRegister(){
        Map<String,Object>map = new HashMap<>();
        map.put("bool","false");
        return R.ok().put("data",map);
    }



}
